<template>
  <div>
    <el-card>
      <el-form ref="form" :model="form" class="form" :inline="true" size="mini">
        <el-form-item label="店铺编号/名称：" class="name">
          <el-input v-model="form.name" style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="行业">
    <el-select v-model="form.region" placeholder="请选择活动区域">
      <el-option label="行业" value="shanghai"></el-option>
      <el-option label="行业" value="beijing"></el-option>
    </el-select>
  </el-form-item>
         <el-form-item label="-">
    <el-select v-model="form.region" placeholder="请选择活动区域">
      <el-option label="1" value="shanghai"></el-option>
      <el-option label="2" value="beijing"></el-option>
    </el-select>
  </el-form-item>
        <div class="buttonL">
          <el-button type="primary" size="small" @click="search()">查询</el-button>
          <el-button size="small" @click="resetForm">重置</el-button>
        </div>
      </el-form>
    </el-card>
    <el-card>
      <el-table border :data="tableData" row-key="id">
        <el-table-column label="店铺编号" prop="id" align="center" />
        <el-table-column label="店铺名称" prop="name" align="center" />
        <el-table-column label="店铺行业" prop="phone" align="center" />
        <el-table-column label="店铺地址" prop="storequantity" align="center" />
        <el-table-column label="联系电话" prop="quantity" align="center" />
        <el-table-column label="推广人ID" prop="money" align="center" />
        <el-table-column label="状态" prop="frequency" align="center" />
        <el-table-column label="备注" prop="frequency" align="center" />
        <el-table-column align="center" label="操作">
          <el-button type="primary" size="small" @click="$router.push('/AuditManagement')">审核</el-button>
        </el-table-column>
      </el-table>
          <el-pagination
            :current-page="page.page"
            :page-size="page.size"
            :page-sizes="[2,3,5,10]"
            layout="total, sizes, prev, pager, next, jumper"
            :total="page.total"
            @current-change="changePage"
            @size-change="changeSize"
          />
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'Audit',
  computed: {
    goodsNum () {
      let sum = 0
      for (let i = 0; i < this.tableData.length; i++) {
        sum += this.tableData[i].quantity
      }
      return sum
    },
    Totalconsumption () {
      let sum = 0
      for (let i = 0; i < this.tableData.length; i++) {
        sum += parseFloat(this.tableData[i].money)
      }
      return sum
    }
  },
  data () {
    return {
      // 表格数据
      tableData: [
        {
          id: 16544851,
          name: '美宜佳-保利店',
          phone: '行业1',
          storequantity: '岳麓区.保利林语..',
          quantity: '188xxxxxxxx',
          money: 1254855,
          frequency: '审核通过',
          time: '审核备注'
        }, {
          id: 16544852,
          name: '美宜佳-保利店',
          phone: '行业1',
          storequantity: '岳麓区.保利林语..',
          quantity: '188xxxxxxxx',
          money: 1254855,
          frequency: '审核通过',
          time: '审核备注'
        }, {
          id: 16544853,
          name: '美宜佳-保利店',
          phone: '行业1',
          storequantity: '岳麓区.保利林语..',
          quantity: '188xxxxxxxx',
          money: 1254855,
          frequency: '审核通过',
          time: '审核备注'
        }, {
          id: 16544854,
          name: '美宜佳-保利店',
          phone: '行业1',
          storequantity: '岳麓区.保利林语..',
          quantity: '188xxxxxxxx',
          money: 1254855,
          frequency: '审核通过',
          time: '审核备注'
        }, {
          id: 16544855,
          name: '美宜佳-保利店',
          phone: '行业1',
          storequantity: '岳麓区.保利林语..',
          quantity: '188xxxxxxxx',
          money: 1254855,
          frequency: '审核通过',
          time: '审核备注'
        }, {
          id: 16544856,
          name: '美宜佳-保利店',
          phone: '行业1',
          storequantity: '岳麓区.保利林语..',
          quantity: '188xxxxxxxx',
          money: 1254855,
          frequency: '审核通过',
          time: '审核备注'
        }, {
          id: 16544857,
          name: '美宜佳-保利店',
          phone: '行业1',
          storequantity: '岳麓区.保利林语..',
          quantity: '188xxxxxxxx',
          money: 1254855,
          frequency: '审核通过',
          time: '审核备注'
        }
      ],
      // 翻页
      currentPage: 1,
      page: {
        page: 1,
        size: 10,
        total: 7
      },
      // 查询数据
      form: {
        name: '',
        time: '',
        region: ''
      },
      timeList: []
    }
  },
  methods: {
    isDuringDate (beginDateStr, endDateStr) {
      // var curDate = new Date(this.tableData[0].time)
      const beginDate = new Date(beginDateStr)
      const endDate = new Date(endDateStr)
      for (let i = 0; i < this.tableData.length; i++) {
        if (new Date(this.tableData[i].time) >= beginDate && new Date(this.tableData[i].time) <= endDate) {
          this.timeList.push(this.tableData[i].time)
        }
      }
      console.log(this.timeList)
    },
    search () {
      this.isDuringDate(this.form.time[0], this.form.time[1])
    },
    resetForm () {
      console.log('重置')
      this.form.name = ''
      this.form.time = ''
    },
    changePage (newPage) {
      this.page.page = newPage
    },
    changeSize (newSize) {
      this.page.size = newSize
    },
    handleCommand (command) {
      this.$message('click on item ' + command)
    }
  }
}
</script>

<style lang="less" scoped>
.form {
  box-sizing: border-box;
}
.el-row {
  padding-left: 20px;
  margin-top: 20px;
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.buttonL {
  padding-left: 30px;
  display: inline-block;
}
.el-button + .el-button {
  margin-left: 30px;
}
</style>
